﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DisableContextMenuItems
{
    public partial class Login : Form
    {
        public Login()
        {

            this.KeyPreview = true;  // 启用窗体的键盘预览
            this.KeyPress += Login_KeyPress;  // 绑定键盘按键事件
            InitializeComponent();
            this.MouseClick += new MouseEventHandler(login_MouserClick);
        }
        private void Login_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)  // 判断按下的键是否为回车键
            {
                // 在这里编写回车键处理的代码
                pictureBox4_Click(sender, e);  // 调用点击图片的方法
            }
        }
        private void login_MouserClick(object sender, EventArgs e)
        {

        }
        private void username_TextChanged(object sender, EventArgs e)
        {

        }

        private void password_TextChanged(object sender, EventArgs e)
        {
            password.PasswordChar = '*';   //显示*
        }

        private void pictureBox4_Click(object sender, EventArgs e)
        {
            if(username.Text == "zb2023" && password.Text == "zb2023")
            {
                this.Close();
                pictureBox4.Click += pictureBox4_Click;
                frmMain f = new frmMain();
                f.Show();
               
            }
            else
            {
                MessageBox.Show("用户名或密码错误，请重新输入！");
            }
        }
    }
}
